package com.iptv.grape.video;

import android.view.Gravity;
import android.widget.FrameLayout;

import com.iptv.grape.RunTimeApplication;

// 视频尺寸
public class VideoSize {
    // 宽度
    private int width;
    // 高度
    private int height;
    // 小窗口left值
    private int left;
    // 小窗口top值
    private int top;

    // 构造函数
    public VideoSize(int width, int height, int left, int top) {
        this.width = width;
        this.height = height;
        this.left = left;
        this.top = top;
    }

    // 返回LayoutParams
    public FrameLayout.LayoutParams getLayoutParams(){
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(this.width, this.height);

        lp.gravity = Gravity.LEFT|Gravity.TOP;
        lp.leftMargin = this.left;
        lp.topMargin = this.top;
        return lp;
    }

    // 返回LayoutParams
    public FrameLayout.LayoutParams getProbarLayoutParams(boolean isFull){

        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(50, 50);
        lp.gravity = Gravity.LEFT | Gravity.TOP;
        if(!isFull) {
            lp.leftMargin = (this.left + (this.width / 2) - 25);
            lp.topMargin = (this.top + (this.height / 2) - 25);
        }
        else {
            lp.leftMargin = ((RunTimeApplication.getCurApp().getDevicewidth() / 2) - 25);
            lp.topMargin = ((RunTimeApplication.getCurApp().getDeviceHeigth() / 2) - 25);
        }
        return lp;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public int getLeft() {
        return left;
    }

    public void setLeft(int left) {
        this.left = left;
    }

    public int getTop() {
        return top;
    }

    public void setTop(int top) {
        this.top = top;
    }


    // 获得一个全屏的参数
    public static FrameLayout.LayoutParams getFullLayoutParams(){
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
        lp.gravity = Gravity.LEFT|Gravity.TOP;
        lp.leftMargin = 0;
        lp.topMargin = 0;
        return lp;
    }
}
